package com.simple.group;

import android.view.ViewGroup;
import android.widget.TextView;

import androidx.core.content.ContextCompat;
import androidx.core.content.res.ResourcesCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;


import com.itemlib.ItemDecoration;
import com.mobileframe.activity.BaseActivity;
import com.simple.R;
import com.simple.databinding.ActivityMainBinding;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends BaseActivity<ActivityMainBinding> {

    RecyclerView recyclerView;
    GroupAdapter itemAdapter;

    @Override
    protected int getLayoutId() {
        return 0;
    }

    @Override
    protected void initView() {
        setTitle("主页");
        recyclerView = mViewBinding.recyclerView;
        //recyclerView = findViewById(R.id.recyclerView);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        TextView textView = new TextView(this);
        textView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        textView.setText("特仑苏就算了加了时间沙漏");
        textView.setTextColor(ContextCompat.getColor(this, R.color.black));

        List<Team> list = new ArrayList<>();
        Team team = new Team();
        team.teamName = "1111";
        List<Member> child1 = new ArrayList<>();
        Member member1 = new Member();
        member1.name = "11111 child";
        child1.add(member1);
        team.teams = child1;
        list.add(team);

        Team team2 = new Team();
        team2.teamName = "22222";
        List<Member> child2 = new ArrayList<>();
        Member member2 = new Member();
        member2.name = "22222 child";

        Member member22 = new Member();
        member22.name = "22222 child 222";

        child2.add(member2);
        child2.add(member22);
        team2.teams = child2;
        list.add(team2);
        itemAdapter = new GroupAdapter(this);
        itemAdapter.setData(list);

        ItemDecoration decoration = new ItemDecoration(itemAdapter);
        decoration.setGroupDivider(ResourcesCompat.getDrawable(getResources(), R.drawable.divider_height_16_dp, null));
        decoration.setChildHeaderDivider(ResourcesCompat.getDrawable(getResources(), R.drawable.divider_child_header, null));
        decoration.setChildDivider(ResourcesCompat.getDrawable(getResources(), R.drawable.divider_child_item, null));
        recyclerView.addItemDecoration(decoration);
        recyclerView.setAdapter(itemAdapter);
    }
}